import 'dart:convert';

class MessageSectionEntity {
  List<MessageSectionInfo>? rows;
  MessageSectionEntity({this.rows});

  factory MessageSectionEntity.fromJson(Map<String, dynamic> json) {
    final originList = json['rows'] as List?;
    List<MessageSectionInfo> protocolList =
        (originList??[]).map((value) => MessageSectionInfo.fromJson(value)).toList();
    return MessageSectionEntity(
      rows: protocolList,
    );
  }
}

class MessageSectionInfo {
  String? name;
  String? detail;
  String? avatar;
  String? createdDate;
  String? lastMsgTime;
  int? id;
  int? unreadCount;
  LastMsgInfo? lastMsg;

  MessageSectionInfo({
    this.name,
    this.detail,
    this.createdDate,
    this.id,
    this.avatar,
    this.lastMsgTime,
    this.lastMsg,
    this.unreadCount,
  });

  MessageSectionInfo.fromJson(Map data) {
    lastMsg = LastMsgInfo.fromJson(jsonDecode(data['lastMsg']));
    name = data['name'];
    detail = data['detail'];
    createdDate = data['createdDate'];
    id = data['id'];
    avatar = data['avatar'];
    lastMsgTime = data['lastMsgTime'];
    unreadCount = data['unreadCount'];
  }
}

class LastMsgInfo {
  String? content;
  // String detail;
  // String avatar;
  // String createdDate;
  // String lastMsgTime;
  // String lastMsg;
  // int id;

  LastMsgInfo({
    this.content,
    // this.detail,
    // this.createdDate,
    // this.id,
    // this.avatar,
    // this.lastMsgTime,
    // this.lastMsg,
  });

  LastMsgInfo.fromJson(Map data) {
    content = data['content'];
    // detail = data['detail'];
    // createdDate = data['createdDate'];
    // id = data['id'];
    // avatar = data['avatar'];
    // lastMsgTime = data['lastMsgTime'];
    // lastMsg = data['lastMsg'];
  }
}
